# # 列表内元素可以是任意类型
# list1 = [123, 3.14, "字符串", (1, 2, 3), [1, 2], {'key': "value"}]
# print(list1)
# print(type(list1))

# list2 = [123]
# print(list2)
# print(type(list2))

# # 获取列表中的元素
# list1 = [123, 3.14, "字符串", (1, 2, 3), [1, 2], {'key': "value"}]
# # print(list1[0])
# # print(list1[2])
# # print(list1[-1])
# print(list1[1:4:2])
# print(list1[1:])

# list1 = [123, 3.14, "字符串", (1, 2, 3), [1, 2], {'key': "value"}]
# # list1[2] = '坚果'
# # print(list1)
# # list1[2:] = ['你好', '坚果']
# # print(list1)
# list1[::2] = '坚果1'
# print(list1)


# 删除列表元素或者列表
# list1 = [123, 3.14, "字符串", (1, 2, 3), [1, 2], {'key': "value"}]
# # del list1[3::2]
# # print(list1)
#
# del list1
# print(list1)

# # list常用的运算符
# list1 = [123, 3.14, "字符串", (1, 2, 3), [1, 2], {'key': "value"}]
# list2 = ['a', 'bc']
# # print(list1 + list2)
# # print(list2*2)
# print(12 not in list1)
# print(123 in list1)

# 列表的常用方法
# list1 = ['NN', 221, 'NN', 246, 'MS246']
# list1.append('坚果')  # 列表最后添加新元素（追加新元素）
# list1.extend([6, 7, 8])  # 追加多个元素
# list1.append([6, 7, 8])
# list1.insert(1, ['a', 'b'])  # 指定索引位置，添加元素
# value = list1.pop()  # 默认移除最后的一个元素，可以指定下标，并返回删除的值
# print(value)
# list1.remove('NN')  # 根据指定的值进行移除，,如果有重名元素，默认删除从左数第一个
# list1.reverse()  # 反转列表元素

# list1 = [123, 221, 0, 246, 56, 1.2]
# list1.sort()  # 排序  默认升序
# list1.sort(reverse=True)  # 降序

# list1.clear()  # 清空列表元素
# print(list1)

# list1 = ['NN', 221, 'NN', 246, 'MS246']
# index_value = list1.index('MS246')  # 获取元素下标
# print(index_value)

# count_value = list1.count('NN')  # 统计列表有几个指定元素
# print(count_value)

# tup1 = (1, 2, 3)
# print(type(tup1))
# list2 = list(tup1) # 元组转换列表
# print(list2)
# print(type(list2))

# list1 = ['NN', 221, 'NN', 246, 'MS246']
# len_value = len(list1)  # 获取列表长度
# print(len_value)

# print(list1)
# list1 = [123, 221, 0, 246, 56]
# print(min(list1))  # 获取最小值
# print(max(list1))  # 获取最大值


b = ['tom', 'lily', 'hom', 'abcde']
# r = [name for name in b if len(name) > 3]
# r = []
# for name in b:
#     if len(name) > 3:
#         r.append(name)
# print(r)
r = [name.capitalize() for name in b if len(name) > 3]
print(r)
print(b)